﻿using System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace BuddyTracker.ViewModel.Helpers
{
    /// <summary>
    /// Helper class for navigating around XAML pages.
    /// </summary>
    public static class NavigationService
    {
        /// <summary>
        /// Navigates to the desired page.
        /// </summary>
        /// <param name="SourcePageType">Type of desired page.</param>
        public static void Navigate(Type SourcePageType)
        {
            var f = Window.Current.Content as Frame;
            f.Navigate(SourcePageType);            
        }

        /// <summary>
        /// Navigates to the desired page and passes a parameter.
        /// </summary>
        /// <param name="SourcePageType">Type of desired page.</param>
        /// <param name="parameter">Object parameter.</param>
        public static void Navigate(Type SourcePageType, object parameter)
        {
            var f = Window.Current.Content as Frame;
            f.Navigate(SourcePageType, parameter);
        }

        /// <summary>
        /// Goes back the navigation stack if possible.
        /// </summary>
        public static void GoBack()
        {
            var f = Window.Current.Content as Frame;
            if (f.CanGoBack)
                f.GoBack();
           
        }
    }
}
